4.5 Output Text Box

The Outbox class is derived from two base classes - display and object. It is a kind of a text window for messages. Of course it is not a fully-fledged text window. You hardly can use Outbox for editing files. But it suits well for outputting text information for various purposes. The more complete text window may be derived from Outbox and will be included in the following versions of Virtual Panels.

* Background mode. It is a mode supported by Outbox printing method. If the background mode is on then printing the new text over the old one will purge away the latter. If it is off (transparent mode) then the new text will be printed over the old one without background. This mode works only if the current mode of text justification is LEFT_TEXT. For other text justifications background mode is always off.

Constructor:

Outbox(
int x0, int y0, // coord. of LEFT-TOP corner of Indicator
objtype type, // may be FIXED, PERM, POPUP
char * title, // title of Outbox
int colomns, int rows,// size of box in characters
//———- Hereafter are defaults
int frame = FRAMED, // display may FRAMED or UNFRAMED
// procedure supplied by programmer to repaint Outbox
void (far * paintproc)() = procNULL,
// font
int titlefont = 0, int titlefontsize = 1,// of title
int textfont = SMALL_FONT, int textfontsize = 5,// of text
// colors
plaquecolors obxcolcnfg = plaquecoldflt,// of frame
outboxcolors obxcolors = obxcoldflt, // of display
int titlejustify = CENTER_TEXT); // for system use

Most of parameters of constructor are typical for Objects. About color schemes see the corresponding subsection below.

Data members:

All are inherited from the object base class ( See sect. 4 ).

Methods:

Includes methods inherited from the object base class ( sect.4 )

virtual void Paint(void);

Paints Outbox clears display, and resets current printing position (it will be at the LEFT-TOP corner of display). Text justification will be LEFT_TEXT.

void SetTextJustify( text_just xtextjust = LEFT_TEXT);

Justifies text in the x-direction and performs Line Feed (LF). The xtextjust may be LEFT_TEXT, CENTER_TEXT or RIGHT_TEXT.

virtual void cls();

Clears display, and resets the current printing position.

void GotoXY( int column, int row);

Moves the printing position to the column and row. If row = -1 then the printing position moves to the bottom of the display.

void GetXY(int * column,int * row);

Gets the current printing position.

void SetTextColor( COLORS newcolor);

Changes current text foreground color to the newcolor.

void SetHLTextColor(COLORS newHighLightcolor);

Changes current highlight text color to the newHighLightcolor.

void YesBkgnd(void);
void NoBkgnd(void);

Switches background mode on or off.

void Put( char *text, int highlight = OFF);
void Putn( char *text, int highlight = OFF);

Prints a string. String is highlighted if highlight = ON. Putn also performs carriage return.

int Printf( int hilight, const char *format, ...);
int Printfn( int hilight, const char *format, ...);

Send formatted output to Outbox. Behave exactly like printf, except for they don't accept control characters. Text is highlighted if highlight = ON. Printfn also performs carriage return.

Color schemes:

Color pattern for the Outbox class is provided by the structure:

struct outboxcolors { COLORS
                        title,
                        text,
                        hltext, // highlighted text
                        paper; };

Default color scheme is:

const outboxcolors obxcoldflt =
                   { RED, WHITE, YELLOW, LIGHTGRAY };
                // title   text  hltext      paper

For Error Message Box you can use a color scheme defined in the header file:

const plaquecolors  errboxcolors = { RED, RED, LIGHTRED };
const outboxcolors  errcolors = { WHITE, WHITE, YELLOW, RED };

Example:
See Example 3.1.2, where the use of the Outbox and its methods is illustrated.